package com.interceptor;

import java.util.Map;

import com.entity.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;


public class LoginInterceptor extends AbstractInterceptor{

	private static final long serialVersionUID = 8455597872569428753L;

	@SuppressWarnings("unchecked")
    @Override
    public String intercept(ActionInvocation inv) throws Exception {
        ActionContext ac=  inv.getInvocationContext();
        Map session=ac.getSession();
        User user=(User)session.get("user");
        if(user!=null){
        	String result;
        	//System.out.println("执行拦截器前");
        	result=inv.invoke();
        	//System.out.println("执行拦截器后");
        	return result;
        }
        return "gotoLogin";
    }
}